/**
 * projectName: springboot-mybatis
 * fileName: WebMvcConfig.java
 * packageName: com.zb.api.business.interceptor
 * date: 2022-02-21 13:33
 * copyright(c) 2017-2020 xxx公司
 */
package com.zb.api.business.interceptor;
/**
 * @version: V1.0
 * @author: fendo
 * @className: WebMvcConfig
 * @packageName: com.zb.api.business.interceptor
 * @description: 拦截器配置
 * @data: 2022-02-21 13:33
 **/

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @description:
 * @author: User
 * @date: 2022-02-21 13:33
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(myInterceptor())
                // 拦截的请求
                .addPathPatterns("/**")
                // 不拦截的请求
                .excludePathPatterns("/testBoot/login",
                        "/testBoot/register",
                        "/captcha/getCodeImg",
                        "/currency/fileUpload",
                        "/testBoot/checkUserNameRepeat/*",
                        "/PosUserCollect/delUserCollect");
        //.addPathPatterns("/currency/fileUpload");

    }

    // 将自定义的拦截器创建为bean对象
    @Bean
    JwtInterceptor myInterceptor(){
        return new JwtInterceptor();
    }
}